//
//  ZLSystemCapture.h
//  Video
//
//  Created by os on 2021/3/26.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>

/// 捕获类型
typedef NS_ENUM(NSUInteger, ZLSystemCaptureType) {
    ZLSystemCaptureTypeVideo = 0,
    ZLSystemCaptureTypeAudio,
    ZLSystemCaptureTypeAll,
};

@protocol ZLSystemCaptureDelegate <NSObject>

@optional

- (void)captureSampleBuffer:(CMSampleBufferRef _Nullable )sampleBuffer type:(ZLSystemCaptureType)type;

@end

NS_ASSUME_NONNULL_BEGIN

/// 捕获音视频
@interface ZLSystemCapture : NSObject

/// 预览层
@property (nonatomic, strong) UIView *preview;
/// 捕获视频的宽
@property (nonatomic, assign, readonly) NSUInteger width;
/// 捕获视频的高
@property (nonatomic, assign, readonly) NSUInteger height;

@property (nonatomic, weak) id<ZLSystemCaptureDelegate> delegate;

/// 初始化
- (instancetype)initWithType:(ZLSystemCaptureType)type;
- (instancetype)init UNAVAILABLE_ATTRIBUTE;

/// 捕获音频时调用
- (void)prepare;
/// 捕获视频时调用（预览层大小，添加到 view 上用来显示）
- (void)prepareWithPreviewsize:(CGSize)size;

/// 开始
- (void)start;
/// 结束
- (void)stop;
/// 切换摄像头
- (void)changeCamera;

/// 授权检测
+ (int)checkMicrophoneAuthor;
+ (int)checkCameraAuthor;

@end

NS_ASSUME_NONNULL_END
